<?php 
    // http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html
?>

<div class="search-box">
	<?php 
		echo $this->Form->create(null, array('url' => array('controller' => 'users', 'action' => 'search')));
		
		echo $this->Form->input('Search', array('type' => 'text', 'name' => 'search'));
		
		echo $this->Form->input('Project name', array('type' => 'checkbox', 'name' => 'projectName'));
		
		echo $this->Form->input('Project annotation', array('type' => 'checkbox', 'name' => 'annotation'));
		
		echo $this->Form->input('Leader name', array('type' => 'checkbox', 'name' => 'leaderName'));
		
		
		echo $this->Form->end('Search');
	?>
</div>


<table>
    <tr>
        <th><?php echo $this->Paginator->sort('id', 'ID'); ?></th>
        <th><?php echo $this->Paginator->sort('username', 'Username'); ?></th>
        <th><?php echo $this->Paginator->sort('userlevel', 'UserLevel'); ?></th>
        <th><?php echo $this->Paginator->sort('Leader.lastname', 'Leader'); ?></th>
        <th>Actions</th>
    </tr>
       <?php foreach($data as $project): ?>
    <tr>
        <td><?php echo $project['Project']['id']; ?> </td>
        <td><?php echo $project['Project']['name']; ?> </td>
        <td><?php echo $project['Project']['annotation']; ?> </td>
        <td><?php echo $project['Leader']['fullname']; ?> </td>
        <td>
        	<?php 
        		echo $this->Html->link('Edit', array('admin' => true, 'controller' => 'projects', 'action' => 'edit', $project['Project']['id']));
        		echo ' | ';
        		echo $this->Html->link('Del', array('admin' => true, 'controller' => 'projects', 'action' => 'delete', $project['Project']['id']), array(), 'Are you sure?');
        	?> 
        </td>
    </tr>
    <?php endforeach; ?>
</table>

<?php 
// Shows the page numbers
echo $this->Paginator->numbers();

// Shows the prev link
echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled'));

// prints X of Y, where X is current page and Y is number of pages
echo $this->Paginator->counter();

// Shows the next link
echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled'));

?>
